/**
 * @param {number} n
 * @return {number}
 */
var fib = function(n) {
    if(n === 0) return 0
    if(n === 1) return 1
    let left = 0, right = 1;
    let temp;
    for(let i = 2; i <= n; i++) {
        temp = right
        right = left + right;
        left = temp
    }
    return right
};
console.log(fib(4));